package wangxu

import (
	"context"
	"fmt"
	"github.com/beherochuling/beesoft_api/app/helper/net"
	"strings"
)

type wangxuVip struct{}

func (r wangxuVip) getUrl(pattern ...string) string {
	var items []string
	if pattern != nil && len(pattern) > 0 {
		for _, p := range pattern {
			items = append(items, strings.Trim(p, "/"))
		}
	}

	return fmt.Sprintf("%s/%s", "http://gw.aoscdn.com/base/vip/v2", strings.Join(items, "/"))
}
func (r wangxuVip) httpPost(ctx context.Context, url string, data interface{}, seconds uint, headers ...map[string]string) {
	client := net.NewHttp(ctx).SetTimeout(seconds)
	if headers != nil && len(headers) > 0 {
		client.SetHeaders(headers[0])
	}
	res := client.Post(url, data)
	fmt.Println(res)
}

// ### 订单

func (r wangxuVip) TransactionCaptured(ctx context.Context, data interface{}) {
	uri := r.getUrl("server/transactions/capture")
	r.httpPost(ctx, uri, data, 3, map[string]string{})
}
func (r wangxuVip) TransactionRefunded(ctx context.Context, data interface{}) {
	uri := r.getUrl("server/transactions/refund")
	r.httpPost(ctx, uri, data, 3, map[string]string{})
}
